package net.aiion.weave.reader;

import net.aiion.weave.impl.resources.ResourceFinderImpl;
import net.aiion.weave.spi.resources.Resource;
import net.aiion.weave.spi.resources.ResourceFinder;
import net.aiion.weave.spi.resources.ResourceListener;

public class Main
{
    public static void main(String[] args) {

        final ResourceFinder resourceFinder = new ResourceFinderImpl();
        resourceFinder.addResourceListener(new ResourceListener()
        {
            @Override
            public void resourceFound(Resource aResource) {
                if (aResource.getName().endsWith(".xml") || aResource.getName().endsWith(".xhtml"))
                    System.out.println(aResource.getName() + "(" + aResource.getURL() + ")");
            }
        });
        resourceFinder.findResources();

        // Source s = new Source();
        // s.addSink(new Sink()
        // {
        // @Override
        // public void handleEvent(Context c) {
        // // System.out.println("S1: " + c.getEvent().getValue());
        // if ("Hello".equals(c.getEvent().getValue())) {
        // c.forwardEvent(new Event("AAAA"));
        // c.forwardEvent(new Event("BBBBB"));
        // c.forwardEvent(c.getEvent());
        // } else if ("!".equals(c.getEvent().getValue())) {
        // c.forwardEvent(new Event("."));
        // } else {
        // c.forwardEvent(c.getEvent());
        // }
        // }
        // });
        // s.addSink(new Sink()
        // {
        // @Override
        // public void handleEvent(Context c) {
        // System.out.println("S2: " + c.getEvent().getValue());
        // if (!".".equals(c.getEvent().getValue())) {
        // c.forwardEvent(c.getEvent());
        // }
        // }
        // });
        // s.addSink(new Sink()
        // {
        // @Override
        // public void handleEvent(Context c) {
        // System.out.println("S3: " + c.getEvent().getValue());
        // }
        // });
        // s.readEvents();
    }
}
